package main;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
import java.util.Vector;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.FlowLayout;

import javax.swing.JOptionPane;
import javax.swing.JToggleButton;
import javax.swing.BoxLayout;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JLabel;
import net.miginfocom.swing.MigLayout;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JComboBox;

import org.eclipse.swt.widgets.MessageBox;

import com.mysql.jdbc.ResultSetMetaData;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;

import javax.swing.JPasswordField;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JCheckBox;

public class TTKhachHang extends JFrame {

	private static final long serialVersionUID = -6464587060272247354L;
	private Connection con = null;
	Properties props = new Properties();
	DefaultTableModel model;
	Statement st;
	ResultSet rs;
	private JTable jTable1;
	private JTextField textSearchKH;
	private JTextField textField;
	private JTextField textField_1;
	private JTextField textField_2;
	private JTextField textField_3;
	private JTextField textField_4;
	private JTextField textField_5;
	private JTextField textField_6;
	private JTextField textField_7;
	private JTextField txtMaSo;
	private JTextField txtHoTen;
	private JTextField txtNgaySinh;
	private JTextField txtDiaChi;
	public JTextField txtSoThueBao;
	private JTextField txtNgayDK;
	private JTextField txtNoiDK;
	private JTextField txtTenGC;
	private JPasswordField passMatKhau;
	private JPasswordField passXacNhan;
	private JComboBox comboGioiTinh;
	JButton btnSua, btnHuy;
	final Vector vtColumn;
	Vector vtRow;
	final Vector vtData;

	// private DefaultTableModel tableModel = new DefaultTableModel();

	public TTKhachHang() throws SQLException {
		vtData = new Vector();
		vtColumn = new Vector();

		vtColumn.add("Mã số");
		vtColumn.add("Họ và tên");
		vtColumn.add("Giới tính");
		vtColumn.add("Ngày sinh");
		vtColumn.add("Địa chỉ");
		vtColumn.add("Số đăng ký");
		vtColumn.add("Ngày đăng ký");
		vtColumn.add("Nơi đăng ký");
		vtColumn.add("Gói cước");
		// vtData.add(vtColumn);

		try {
			Class.forName("com.mysql.jdbc.Driver");
			props.setProperty("user", "root");
			props.setProperty("password", "");
			props.setProperty("con", "utf8_unicode_ci");
			con = DriverManager.getConnection(
					"jdbc:mysql://localhost:3306/qlsodt", props);
			// Khởi tạo đối tượng Statement
			st = con.createStatement();
			// cho phép gửi câu lệnh sql
			rs = st.executeQuery("select * from khachhang ");
			if (rs != null) {
				while (rs.next()) {
					vtRow = new Vector();
					vtRow.add(rs.getString("MaKH"));
					vtRow.add(rs.getString("TenKH"));
					vtRow.add(rs.getString("GioiTinhKH"));
					vtRow.add(rs.getString("NgaySinhKH"));
					vtRow.add(rs.getString("DiaChiKH"));
					vtRow.add(rs.getString("SoThueBao"));
					vtRow.add(rs.getString("NgayDK"));
					vtRow.add(rs.getString("NoiDK"));
					vtRow.add(rs.getString("MaGC"));
					vtData.add(vtRow);
				}
			}
			getContentPane().setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
			// Taoj table vaf load csdl len jtextfiled
			jTable1 = new JTable();

			// model.fireTableDataChanged();
			jTable1.addMouseListener(new MouseAdapter() {
				@Override
				public void mouseClicked(MouseEvent arg0) {
					model = new DefaultTableModel(vtData, vtColumn);
					int row = jTable1.getSelectedRow();
					txtMaSo.setText(model.getValueAt(row, 0).toString());
					txtHoTen.setText(model.getValueAt(row, 1).toString());
					comboGioiTinh.setSelectedItem(model.getValueAt(row, 2)
							.toString());
					txtNgaySinh.setText(model.getValueAt(row, 3).toString());
					txtDiaChi.setText(model.getValueAt(row, 4).toString());
					txtSoThueBao.setText(model.getValueAt(row, 5).toString());
					txtNgayDK.setText(model.getValueAt(row, 6).toString());
					txtNoiDK.setText(model.getValueAt(row, 7).toString());
					txtTenGC.setText(model.getValueAt(row, 8).toString());

				}
			});
			// jTable1.setAutoResizeMode( );
			JScrollPane scrollPane = new JScrollPane(jTable1);

			getContentPane().add(scrollPane);
			scrollPane.setAutoscrolls(true);
			scrollPane.setPreferredSize(new Dimension(500, 350));

			// panel.add(jTable1);
			model = new DefaultTableModel(vtData, vtColumn);
			jTable1.setModel(model);
			jTable1.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
			jTable1.getColumnModel().getColumn(1).setPreferredWidth(150);
			jTable1.getColumnModel().getColumn(5).setPreferredWidth(100);
			// panel hiển thị tho
			JPanel panel_TKTT = new JPanel();
			getContentPane().add(panel_TKTT);
			panel_TKTT.setLayout(new BoxLayout(panel_TKTT, BoxLayout.Y_AXIS));

			JPanel panelTimKiem = new JPanel();
			panel_TKTT.add(panelTimKiem, BorderLayout.NORTH);

			JLabel lblMSKhch = new JLabel("Mã số khách hàng:");
			panelTimKiem.add(lblMSKhch);

			textSearchKH = new JTextField();
			panelTimKiem.add(textSearchKH);
			textSearchKH.setColumns(20);

			JButton btnNewButton = new JButton("Tìm");
			st = con.createStatement();
			btnNewButton.addActionListener(new ActionListener() {

				public void actionPerformed(ActionEvent e) {

					String sqlfind = "select * from khachhang where MaKH='"
							+ textSearchKH.getText() + "'";
					try {
						st = con.createStatement();
						rs = st.executeQuery(sqlfind);
						// cho phép gửi câu lệnh sql

						// model = new DefaultTableModel(vtData, vtColumn);
						// jTable1.setModel(model(rs.next()));
						jTable1.repaint();

					} catch (SQLException e1) {
						// TODO Auto-generated catch block
						e1.printStackTrace();
					}

				}
			});
			panelTimKiem.add(btnNewButton);

			JPanel panelThongtTin = new JPanel();
			panel_TKTT.add(panelThongtTin);
			panelThongtTin.setPreferredSize(new Dimension(450, 350));
			panelThongtTin.setBackground(Color.LIGHT_GRAY);

			JLabel lblNewLabel = new JLabel("Mã số :");

			txtMaSo = new JTextField();
			txtMaSo.setEditable(false);
			txtMaSo.setColumns(10);

			txtHoTen = new JTextField();
			txtHoTen.setEditable(false);
			txtHoTen.setColumns(10);

			JLabel lblNewLabel_1 = new JLabel("Họ và tên:");

			JLabel lblNewLabel_2 = new JLabel("Giới tính:");
			String[] gt = { "Nam", "Nữ" };
			comboGioiTinh = new JComboBox(gt);

			JLabel lblNewLabel_3 = new JLabel("Ngày sinh:");

			txtNgaySinh = new JTextField();
			txtNgaySinh.setEditable(false);
			txtNgaySinh.setColumns(10);

			JLabel lblNewLabel_4 = new JLabel("Địa chỉ:");

			txtDiaChi = new JTextField();
			txtDiaChi.setEditable(false);
			txtDiaChi.setColumns(10);

			JLabel lblNewLabel_5 = new JLabel("Số thuê bao:");

			txtSoThueBao = new JTextField();
			txtSoThueBao.setEditable(false);
			txtSoThueBao.setColumns(10);

			JLabel lblNewLabel_6 = new JLabel("Ngày đăng ký:");

			txtNgayDK = new JTextField();
			txtNgayDK.setEditable(false);
			txtNgayDK.setColumns(10);

			JLabel lblNewLabel_7 = new JLabel("Nơi đăng ký:");

			txtNoiDK = new JTextField();
			txtNoiDK.setEditable(false);
			txtNoiDK.setColumns(10);

			JLabel lblTnGiCc = new JLabel("Tên gói cước:");

			txtTenGC = new JTextField();
			txtTenGC.setEditable(false);
			txtTenGC.setColumns(10);

			final JButton btnDangKy = new JButton("Đăng ký");
			btnDangKy.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {

					if (btnDangKy.getText() == "Đăng ký") {
						ediTrue();
						clear();
						jTable1.setEnabled(false);
						btnDangKy.setText("Xong");
						btnSua.setText("Hủy");
						btnHuy.setEnabled(false);

					} else {
						if (btnDangKy.getText() == "Hủy") {
							btnDangKy.setText("Đăng ký");
							btnSua.setText("Sửa thông tin");
							btnHuy.setEnabled(true);
							ediFalse();
						} else {

							if (txtMaSo.getText().toString().equals("")
									|| txtHoTen.getText().toString().equals("")
									|| txtNgaySinh.getText().toString()
											.equals("")
									|| passMatKhau.getText().toString()
											.equals("")
									|| txtDiaChi.getText().toString()
											.equals("")
									|| txtSoThueBao.getText().toString()
											.equals("")
									|| txtNgayDK.getText().toString()
											.equals("")
									|| txtNoiDK.getText().toString().equals("")
									|| txtTenGC.getText().toString().equals("")
									|| txtNoiDK.getText().toString().equals("")) {
								JOptionPane.showMessageDialog(TTKhachHang.this,
										"Vui lòng điền đầy đủ thông tin",
										"Lỗi", JOptionPane.ERROR_MESSAGE);

							} else {
								if (passMatKhau
										.getText()
										.toString()
										.equals(passXacNhan.getText()
												.toString())) {
									String sqlInsertKH = "insert into khachhang values('"
											+ txtMaSo.getText()
											+ "','"
											+ passMatKhau.getText()
											+ "','"

											+ txtHoTen.getText()
											+ "','"
											+ comboGioiTinh.getSelectedItem()
													.toString()
											+ "','"
											+ txtNgaySinh.getText()
											+ "','"
											+ txtDiaChi.getText()
											+ "','"
											+ txtSoThueBao.getText()
											+ "','"
											+ txtNgayDK.getText()
											+ "','"
											+ txtNoiDK.getText()
											+ "','"
											+ txtTenGC.getText() + "')";

									Statement st;
									try {
										st = con.createStatement();
										st.execute(sqlInsertKH);
										JOptionPane.showMessageDialog(
												TTKhachHang.this,
												"Đăng ký thành công thuê bao "
														+ txtSoThueBao
																.getText()
																.toString()
														+ ". Mã số đăng ký là "
														+ txtMaSo.getText());
										model = new DefaultTableModel(vtData,
												vtColumn);
										jTable1.setModel(model);
										jTable1.repaint();
										model.addRow(vtData);
										ediFalse();
										btnDangKy.setText("Đăng ký");
										btnSua.setText("Sửa thông tin");
										btnHuy.setEnabled(true);
										jTable1.repaint();
										jTable1.validate();
										jTable1.setEnabled(true);
									} catch (SQLException e) {
										// TODO Auto-generated catch block
										e.printStackTrace();
										JOptionPane.showMessageDialog(
												TTKhachHang.this,
												"Đăng ký thất bại");
									}
								} else
									JOptionPane.showMessageDialog(
											TTKhachHang.this,
											"Mật khẩu không khớp");
							}

						}
					}
				}
			});

			btnSua = new JButton("Sửa thông tin");
			btnSua.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					if (btnSua.getText() == "Hủy") {
						ediFalse();
						btnSua.setText("Sửa thông tin");
						btnDangKy.setText("Đăng ký");
						btnHuy.setEnabled(true);
						jTable1.setEnabled(true);
					} else {
						if (btnSua.getText() == "Xong") {
							String sqlUpdateKH = "update khachhang set TenKH='"
									+ txtHoTen.getText()
									+ "', GioiTinhKH='"
									+ comboGioiTinh.getSelectedItem()
											.toString() + "' , NgaySinhKH='"
									+ txtNgaySinh.getText() + "', DiaChiKH='"
									+ txtDiaChi.getText() + "', SoThueBao='"
									+ txtSoThueBao.getText() + "', NgayDK='"
									+ txtNgayDK.getText() + "', NoiDK='"
									+ txtNoiDK.getText() + "', MaGC='"
									+ txtTenGC.getText() + "' where MaKH='"
									+ txtMaSo.getText() + "'";
							try {
								st = con.createStatement();
								st.execute(sqlUpdateKH);
								JOptionPane.showMessageDialog(TTKhachHang.this,
										"Update thành công thuê bao "
												+ txtSoThueBao.getText()
														.toString()
												+ ". Mã số đăng ký là "
												+ txtMaSo.getText());
								ediFalse();
								btnDangKy.setText("Đăng ký");
								btnHuy.setEnabled(true);
								btnSua.setText("Sửa thông tin");
								jTable1.repaint();
							} catch (SQLException e1) {
								// TODO Auto-generated catch block
								e1.printStackTrace();
								JOptionPane.showMessageDialog(TTKhachHang.this,
										"Update thất bại");
								btnHuy.setEnabled(true);
							}

						} else {
							btnSua.setText("Xong");
							btnDangKy.setText("Hủy");
							ediTrue();
							txtMaSo.setEditable(false);
							passMatKhau.setEditable(false);
							passXacNhan.setEditable(false);
							btnHuy.setEnabled(false);
						}
					}

				}
			});
			btnHuy = new JButton("Hủy đăng ký");
			btnHuy.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					if (txtMaSo.getText().toString().equals("")) {
						JOptionPane.showMessageDialog(TTKhachHang.this,
								"Hãy chọn một mã số!");
					} else {
						String sqldel = "delete from khachhang where MaKH='"
								+ txtMaSo.getText().toString() + "'";
						try {
							st = con.createStatement();
							st.execute(sqldel);
							JOptionPane.showMessageDialog(
									TTKhachHang.this,
									"Hủy thành công khách hàng "
											+ txtMaSo.getText());
							jTable1.repaint();
						} catch (SQLException e1) {
							// TODO Auto-generated catch block
							e1.printStackTrace();
							JOptionPane.showMessageDialog(TTKhachHang.this,
									"Hủy không thành công");
						}
					}
				}
			});

			JLabel lblMtKhu = new JLabel("Mật khẩu:");

			passMatKhau = new JPasswordField();
			passMatKhau.setEditable(false);

			passXacNhan = new JPasswordField();
			passXacNhan.setEditable(false);

			JLabel lblXcNhn = new JLabel("Xác nhận:");

			GroupLayout gl_panelThongtTin = new GroupLayout(panelThongtTin);
			gl_panelThongtTin.setHorizontalGroup(
				gl_panelThongtTin.createParallelGroup(Alignment.LEADING)
					.addGroup(gl_panelThongtTin.createSequentialGroup()
						.addGroup(gl_panelThongtTin.createParallelGroup(Alignment.LEADING)
							.addGroup(gl_panelThongtTin.createSequentialGroup()
								.addContainerGap()
								.addGroup(gl_panelThongtTin.createParallelGroup(Alignment.LEADING)
									.addGroup(gl_panelThongtTin.createSequentialGroup()
										.addGroup(gl_panelThongtTin.createParallelGroup(Alignment.LEADING)
											.addComponent(lblNewLabel)
											.addComponent(lblNewLabel_1))
										.addPreferredGap(ComponentPlacement.RELATED)
										.addGroup(gl_panelThongtTin.createParallelGroup(Alignment.LEADING)
											.addComponent(txtHoTen, GroupLayout.PREFERRED_SIZE, 333, GroupLayout.PREFERRED_SIZE)
											.addComponent(txtMaSo, GroupLayout.PREFERRED_SIZE, 148, GroupLayout.PREFERRED_SIZE)))
									.addGroup(gl_panelThongtTin.createSequentialGroup()
										.addComponent(lblNewLabel_2)
										.addPreferredGap(ComponentPlacement.UNRELATED)
										.addComponent(comboGioiTinh, GroupLayout.PREFERRED_SIZE, 100, GroupLayout.PREFERRED_SIZE))
									.addGroup(gl_panelThongtTin.createSequentialGroup()
										.addComponent(lblNewLabel_5)
										.addPreferredGap(ComponentPlacement.RELATED)
										.addComponent(txtSoThueBao, GroupLayout.PREFERRED_SIZE, 154, GroupLayout.PREFERRED_SIZE))
									.addGroup(gl_panelThongtTin.createSequentialGroup()
										.addComponent(lblNewLabel_6)
										.addPreferredGap(ComponentPlacement.RELATED)
										.addComponent(txtNgayDK, 252, 252, 252))
									.addGroup(gl_panelThongtTin.createSequentialGroup()
										.addComponent(lblNewLabel_7)
										.addPreferredGap(ComponentPlacement.RELATED)
										.addComponent(txtNoiDK, 262, 262, 262))
									.addGroup(gl_panelThongtTin.createSequentialGroup()
										.addComponent(lblNewLabel_3)
										.addPreferredGap(ComponentPlacement.RELATED)
										.addComponent(txtNgaySinh, GroupLayout.PREFERRED_SIZE, 158, GroupLayout.PREFERRED_SIZE))
									.addGroup(gl_panelThongtTin.createSequentialGroup()
										.addComponent(lblNewLabel_4)
										.addGap(18)
										.addComponent(txtDiaChi, GroupLayout.DEFAULT_SIZE, 363, Short.MAX_VALUE))
									.addGroup(gl_panelThongtTin.createSequentialGroup()
										.addComponent(lblTnGiCc)
										.addPreferredGap(ComponentPlacement.RELATED)
										.addComponent(txtTenGC, GroupLayout.PREFERRED_SIZE, 119, GroupLayout.PREFERRED_SIZE))))
							.addGroup(gl_panelThongtTin.createSequentialGroup()
								.addGap(53)
								.addComponent(btnDangKy)
								.addPreferredGap(ComponentPlacement.RELATED)
								.addComponent(btnSua)
								.addPreferredGap(ComponentPlacement.RELATED)
								.addComponent(btnHuy))
							.addGroup(gl_panelThongtTin.createSequentialGroup()
								.addContainerGap()
								.addComponent(lblMtKhu)
								.addPreferredGap(ComponentPlacement.UNRELATED)
								.addComponent(passMatKhau, GroupLayout.PREFERRED_SIZE, 107, GroupLayout.PREFERRED_SIZE)
								.addGap(23)
								.addComponent(lblXcNhn)
								.addPreferredGap(ComponentPlacement.RELATED)
								.addComponent(passXacNhan, GroupLayout.PREFERRED_SIZE, 129, GroupLayout.PREFERRED_SIZE)))
						.addGap(23))
			);
			gl_panelThongtTin.setVerticalGroup(
				gl_panelThongtTin.createParallelGroup(Alignment.LEADING)
					.addGroup(gl_panelThongtTin.createSequentialGroup()
						.addContainerGap()
						.addGroup(gl_panelThongtTin.createParallelGroup(Alignment.BASELINE)
							.addComponent(lblNewLabel)
							.addComponent(txtMaSo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
						.addPreferredGap(ComponentPlacement.RELATED)
						.addGroup(gl_panelThongtTin.createParallelGroup(Alignment.BASELINE)
							.addComponent(lblMtKhu)
							.addComponent(passMatKhau, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
							.addComponent(passXacNhan, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
							.addComponent(lblXcNhn))
						.addPreferredGap(ComponentPlacement.RELATED)
						.addGroup(gl_panelThongtTin.createParallelGroup(Alignment.BASELINE)
							.addComponent(txtHoTen, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
							.addComponent(lblNewLabel_1))
						.addPreferredGap(ComponentPlacement.RELATED)
						.addGroup(gl_panelThongtTin.createParallelGroup(Alignment.BASELINE)
							.addComponent(lblNewLabel_2)
							.addComponent(comboGioiTinh, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
						.addPreferredGap(ComponentPlacement.UNRELATED)
						.addGroup(gl_panelThongtTin.createParallelGroup(Alignment.BASELINE)
							.addComponent(lblNewLabel_3)
							.addComponent(txtNgaySinh, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
						.addPreferredGap(ComponentPlacement.RELATED)
						.addGroup(gl_panelThongtTin.createParallelGroup(Alignment.BASELINE)
							.addComponent(lblNewLabel_4)
							.addComponent(txtDiaChi, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
						.addPreferredGap(ComponentPlacement.RELATED)
						.addGroup(gl_panelThongtTin.createParallelGroup(Alignment.TRAILING)
							.addComponent(lblNewLabel_5)
							.addComponent(txtSoThueBao, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
						.addPreferredGap(ComponentPlacement.RELATED)
						.addGroup(gl_panelThongtTin.createParallelGroup(Alignment.BASELINE)
							.addComponent(lblNewLabel_6)
							.addComponent(txtNgayDK, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
						.addPreferredGap(ComponentPlacement.RELATED)
						.addGroup(gl_panelThongtTin.createParallelGroup(Alignment.BASELINE)
							.addComponent(lblNewLabel_7)
							.addComponent(txtNoiDK, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
						.addPreferredGap(ComponentPlacement.RELATED)
						.addGroup(gl_panelThongtTin.createParallelGroup(Alignment.BASELINE)
							.addComponent(lblTnGiCc)
							.addComponent(txtTenGC, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
						.addGap(18)
						.addGroup(gl_panelThongtTin.createParallelGroup(Alignment.BASELINE)
							.addComponent(btnDangKy)
							.addComponent(btnSua)
							.addComponent(btnHuy))
						.addGap(15))
			);
			panelThongtTin.setLayout(gl_panelThongtTin);

		} catch (Exception ex) {
			System.out.println(ex.toString());
			JOptionPane.showMessageDialog(this,
					"Không thể kết nối với cơ sở dữ liệu! Hãy thử lại");
			con.close();
			this.setVisible(false);
			this.setDefaultCloseOperation(EXIT_ON_CLOSE);

		}
	}

	public static void main(String[] args) throws SQLException {
		TTKhachHang tb = new TTKhachHang();
		tb.setVisible(true);
		tb.setSize(1000, 410);
		tb.setDefaultCloseOperation(EXIT_ON_CLOSE);
		tb.setResizable(false);
	}

	public void clear() {
		txtMaSo.setText("");
		passMatKhau.setText("");
		passXacNhan.setText("");
		txtHoTen.setText("");
		txtNgaySinh.setText("");
		txtDiaChi.setText("");
		txtSoThueBao.setText("");
		txtNgayDK.setText("");
		txtNoiDK.setText("");
		txtTenGC.setText("");
	}

	public void ediTrue() {
		txtMaSo.setEditable(true);
		txtHoTen.setEditable(true);
		passMatKhau.setEditable(true);
		passXacNhan.setEditable(true);
		txtNgaySinh.setEditable(true);
		txtDiaChi.setEditable(true);
		txtSoThueBao.setEditable(true);
		txtNgayDK.setEditable(true);
		txtNoiDK.setEditable(true);
		txtTenGC.setEditable(true);
	}

	public void ediFalse() {
		txtMaSo.setEditable(false);
		txtHoTen.setEditable(false);
		passMatKhau.setEditable(false);
		passXacNhan.setEditable(false);
		txtNgaySinh.setEditable(false);
		txtDiaChi.setEditable(false);
		txtSoThueBao.setEditable(false);
		txtNgayDK.setEditable(false);
		txtNoiDK.setEditable(false);
		txtTenGC.setEditable(false);
	}
}